﻿#include <CommonUnits/Units/Power.h>
#include <gtest/gtest.h>

TEST(PowerTest, CastTest)
{
    EXPECT_EQ(CU::Watt(1e3), CU::Kilowatt(1));
    EXPECT_EQ(CU::Kilowatt(1e3), CU::Megawatt(1));
    EXPECT_EQ(CU::Megawatt(1e3), CU::Gigawatt(1));
    EXPECT_EQ(CU::Gigawatt(1e3), CU::Terawatt(1));
    EXPECT_EQ(CU::Terawatt(1e3), CU::Petawatt(1));
    EXPECT_EQ(CU::Petawatt(1e3), CU::Exawatt(1));
    EXPECT_EQ(CU::Milliwatt(1e3), CU::Watt(1));
    EXPECT_EQ(CU::Microwatt(1e3), CU::Milliwatt(1));
    EXPECT_EQ(CU::Nanowatt(1e3), CU::Microwatt(1));
    EXPECT_EQ(CU::Picowatt(1e3), CU::Nanowatt(1));
    EXPECT_EQ(CU::Femtowatt(1e3), CU::Picowatt(1));
    EXPECT_EQ(CU::Attowatt(1e3), CU::Femtowatt(1));
}

TEST(PowerTest, Literals)
{
    using namespace CU::Power::Literals;
    EXPECT_EQ(1e3_W, 1.0_kW);
    EXPECT_EQ(1e3_kW, 1.0_MW);
    EXPECT_EQ(1e3_MW, 1.0_GW);
    EXPECT_EQ(1e3_GW, 1.0_TW);
    EXPECT_EQ(1e3_TW, 1.0_PW);
    EXPECT_EQ(1e3_PW, 1.0_EW);
    EXPECT_EQ(1e3_mW, 1.0_W);
    EXPECT_EQ(1e3_uW, 1.0_mW);
    EXPECT_EQ(1e3_nW, 1.0_uW);
    EXPECT_EQ(1e3_pW, 1.0_nW);
    EXPECT_EQ(1e3_fW, 1.0_pW);
    EXPECT_EQ(1e3_aW, 1.0_fW);
}

TEST(PowerTest, ToUnit)
{
    using namespace CU::Power::Literals;
    EXPECT_EQ(1e3_W, CU::Power::toUnit<CU::Watt>(1, CU::Kilowatt::unit()));
    EXPECT_EQ(1e3_kW, CU::Power::toUnit<CU::Kilowatt>(1, CU::Megawatt::unit()));
    EXPECT_EQ(1e3_MW, CU::Power::toUnit<CU::Megawatt>(1, CU::Gigawatt::unit()));
    EXPECT_EQ(1e3_GW, CU::Power::toUnit<CU::Gigawatt>(1, CU::Terawatt::unit()));
    EXPECT_EQ(1e3_TW, CU::Power::toUnit<CU::Terawatt>(1, CU::Petawatt::unit()));
    EXPECT_EQ(1e3_PW, CU::Power::toUnit<CU::Petawatt>(1, CU::Exawatt::unit()));
    EXPECT_EQ(1e3_mW, CU::Power::toUnit<CU::Milliwatt>(1, CU::Watt::unit()));
    EXPECT_EQ(1e3_uW, CU::Power::toUnit<CU::Microwatt>(1, CU::Milliwatt::unit()));
    EXPECT_EQ(1e3_nW, CU::Power::toUnit<CU::Nanowatt>(1, CU::Microwatt::unit()));
    EXPECT_EQ(1e3_pW, CU::Power::toUnit<CU::Picowatt>(1, CU::Nanowatt::unit()));
    EXPECT_EQ(1e3_fW, CU::Power::toUnit<CU::Femtowatt>(1, CU::Picowatt::unit()));
    EXPECT_EQ(1e3_aW, CU::Power::toUnit<CU::Attowatt>(1, CU::Femtowatt::unit()));
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}